package top.riske.animalhazardassessment.common.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.riske.animalhazardassessment.common.http.exception.BusinessException;

import java.time.LocalDateTime;

@Tag(name = "MainController", description = "根路径控制器")
@RestController
public class MainController {

    @Operation(summary = "测试系统是否联通")
    @GetMapping("/")
    public String index() {
        return LocalDateTime.now().toString();
    }

    @Operation(summary = "测试空返回值")
    @GetMapping("/void")
    public void returnVoid(){

    }

    @Operation(summary = "测试返回异常")
    @GetMapping("/exception")
    public String businessException(){
        throw new BusinessException("异常");
    }

    @Operation(summary = "测试当前身份是否为管理员")
    @GetMapping("/protected/admin/")
    public String testAdminRole(){
        return "admin";
    }

    @Operation(summary = "测试当前身份是否为用户")
    @GetMapping("/protected/user/")
    public String testUserRole(){
        return "user";
    }
}
